/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metro.jme.lottery.graphics.screens;

import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.Ticker;
import metro.jme.lottery.persist.FavBean;
import metro.jme.lottery.util.StringUtil;

/**
 *
 * @author pierre
 */
public class MainScreen extends Form {
	
	private Image m_title;
	private StringItem m_fav;
	private Ticker m_ticker; 
	
	public MainScreen() {
		// Call superconstructor (Form)
		super("Metropolia Lottery checker");
		
		paint();
		
	}
	
	public void paint() {
		this.deleteAll();
		init();
	}
	
	private void init() {
		
		// Title :
		this.append("Lottery checker !");
		
		// Let's show the favourite set :
		String favSet = FavBean.getFavSet();
		if(StringUtil.isEmpty(favSet)) {
			favSet = "Select a set from the menu";
		}
		
		this.append(new StringItem("Here is your favourite number set", favSet));
		
		// Add a ticket at the bottom of the screen
		this.setTicker(new Ticker("Welcome to the lottery checker, you can compare your favourite numbers with the correct one by using check button"));
	}
	
	
	
	// ...
	protected int[] getFavSet() {
		
		int[] set = {1,2,3,4,5,6,7};
		
		return set;
	}
	
	protected String getSetAsString(int[] set) {
		String concatenatedString = "";
		
		// Add first element,
		concatenatedString += set[0];
		// then others
		for (int i = 1; i < set.length; i++) {
			concatenatedString += "," + set[i];
		}
		
		return concatenatedString;
	}
	
}
